<template>
  <div class="fill-width-height home_container" style="background: #f9f9f9;overflow: auto">
    <div class="flex-row">
      <div class="card_container left-top flex-col" style="width: 45%;gap:10px;">
        <div class="loginName">{{ username }}</div>
        <div>您好，祝您开心每一天！</div>
      </div>
      <div class="flex-1">
        <el-row :gutter="24" :justify="'left'" style="margin: 0">
          <el-col :md="12" :lg="12" :xl="12" :xs="24" :sm="24" class="pd-0">
            <Container :icon="one" title="图片总数" :number="imgTotal"/>
          </el-col>
          <el-col :md="12" :lg="12" :xl="12" :xs="24" :sm="24" class="pd-0">
            <Container :icon="tow" title="下载数" :number="downTotal"/>
          </el-col>
          <el-col :md="12" :lg="12" :xl="12" :xs="24" :sm="24" class="pd-0">
            <Container :icon="three" title="收藏数" :number="collectionTotal"/>
          </el-col>
          <el-col :md="12" :lg="12" :xl="12" :xs="24" :sm="24" class="pd-0">
            <Container :icon="four" title="查看数" :number="lookTotal"/>
          </el-col>
        </el-row>
      </div>
    </div>

    <el-row :gutter="24" :justify="'left'" style="margin: 0">
      <el-col :lg="12" :xl="12" :md="24" :xs="24" :sm="24" class="pd-0">
        <TypeTotal />
      </el-col>
      <el-col  :lg="12" :xl="12" :md="24" :xs="24" :sm="24" class="pd-0">
        <VisTotal />
      </el-col>
      <el-col  :lg="24" :xl="24" :md="24" :xs="24" :sm="24" class="pd-0">
        <AppVisTotal/>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import Container from './components/top/container'
import one from './components/img/1.png'
import tow from './components/img/2.png'
import three from './components/img/3.png'
import four from './components/img/4.png'
import {getCollectionTotal, getDownTotal, getImgTotal, getLookTotal} from "@/api/home";
import TypeTotal from './components/typeTotal'
export default {
  components: {
    Container,
    TypeTotal,
    VisTotal: () => import('./components/visTotal'),
    AppVisTotal: () => import('./components/appVisTotal')
  },
  data(){
    return {
      one: one,
      tow: tow,
      three: three,
      four: four,
      imgTotal: 0,
      downTotal: 0,
      collectionTotal: 0,
      lookTotal: 0
    }
  },
  computed:{
    username(){
      return this.$store.state.user.name;
    }
  },
  methods: {
    async init(){
      this.imgTotal = await getImgTotal().then(res => res.data?.imgTotal || 0)
      this.downTotal = await getDownTotal().then(res => res.data?.downTotal || 0 )
      this.collectionTotal = await getCollectionTotal().then(res => res.data?.collectionTotal || 0)
      this.lookTotal = await getLookTotal().then(res => res.data?.lookTotal || 0)
    }
  },
  mounted() {
    this.init()
  }
}
</script>

<style scoped lang="scss">
  .top_img{
      height: 100%;
      object-fit: contain;
  }
  .loginName{
    font-family: Noto Sans S Chinese;
    font-weight: bold;
    font-size: 31px;
    color: #000000;
    line-height: 60px;
    font-style: italic;
  }
  .left-top{
    background-image: url("./back.png") !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
  }
  .card_container{
    background: #FFFFFF;
    border-radius: 10px;
    padding: 10px;
    min-height: 110px;
  }
  .pd-0{
    //padding: 0 !important;
    padding: 10px;
  }
</style>
